package com.uduew.sjd.view.xpop;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.uduew.sjd.R;
import com.lxj.xpopup.core.CenterPopupView;

//Acclaim Xpop
public class AcclaimXpop extends CenterPopupView implements View.OnClickListener {
    TextView acclaimRefuseBtn, acclaimAgreeBtn;
    ImageView starOne, starTwo, starThree, starFour, starFive;

    public AcclaimXpop(@NonNull Context context) {
        super(context);
    }

    @Override
    protected int getImplLayoutId() {
        return R.layout.xpop_acclaim;
    }

    @Override
    protected void onCreate() {
        super.onCreate();
        acclaimRefuseBtn = findViewById(R.id.acclaimRefuse_btn);
        acclaimAgreeBtn = findViewById(R.id.acclaimAgree_btn);
        starOne = findViewById(R.id.star_one);
        starTwo = findViewById(R.id.star_two);
        starThree = findViewById(R.id.star_three);
        starFour = findViewById(R.id.star_four);
        starFive = findViewById(R.id.star_five);
        starOne.setOnClickListener(this);
        starTwo.setOnClickListener(this);
        starThree.setOnClickListener(this);
        starFour.setOnClickListener(this);
        starFive.setOnClickListener(this);

        acclaimRefuseBtn.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
        acclaimAgreeBtn.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
    }

    @Override
    public void onClick(View v) {
        starOne.setImageResource(R.mipmap.grey_star);
        starTwo.setImageResource(R.mipmap.grey_star);
        starThree.setImageResource(R.mipmap.grey_star);
        starFour.setImageResource(R.mipmap.grey_star);
        starFive.setImageResource(R.mipmap.grey_star);
        if (v.getId() == R.id.star_one) {
            starOne.setImageResource(R.mipmap.yellow_star);
        }
        if (v.getId() == R.id.star_two) {
            starOne.setImageResource(R.mipmap.yellow_star);
            starTwo.setImageResource(R.mipmap.yellow_star);
        }
        if (v.getId() == R.id.star_three) {
            starOne.setImageResource(R.mipmap.yellow_star);
            starTwo.setImageResource(R.mipmap.yellow_star);
            starThree.setImageResource(R.mipmap.yellow_star);
        }
        if (v.getId() == R.id.star_four) {
            starOne.setImageResource(R.mipmap.yellow_star);
            starTwo.setImageResource(R.mipmap.yellow_star);
            starThree.setImageResource(R.mipmap.yellow_star);
            starFour.setImageResource(R.mipmap.yellow_star);
        }
        if (v.getId() == R.id.star_five) {
            starOne.setImageResource(R.mipmap.yellow_star);
            starTwo.setImageResource(R.mipmap.yellow_star);
            starThree.setImageResource(R.mipmap.yellow_star);
            starFour.setImageResource(R.mipmap.yellow_star);
            starFive.setImageResource(R.mipmap.yellow_star);
        }
    }
}